import { dataSourceType } from "@/type";

export const checkNameForm = async (_rule: dataSourceType = {}, value: any, callback: any = () => { }) => {
  if (_rule.required) {
    if (!value || value == undefined || (_rule.type == 'Array' && value.length == 0)) {
      return Promise.reject(`${_rule.msg1}`);
    } else {
      return Promise.resolve()
    }
  } else {
    return Promise.resolve()
  }
};

const defaultLeftComp = [
  {
    "value": "",
    "placeholder": "请输入",
    "param": "title",
    rule: {
      "required": true,
      "trigger": [
        "blur"
      ],
      "msg1": "标题不能为空!",
      validator: checkNameForm,
      "msg2": "名称不能重复!",
      "key": "siteDomain"
    },
    "label": "标题:",
    "beforeText": "",
    "afterText": "",
    "helpMsg": "",
    "api": "fetchOssNameUnique",
    "width": 492,
    "maxCount": 500,
    "showCount": true,
    "marginLeft": 32,
    "marginTop": 0,
    "type": "textInput",
    "associated": "",
    "associatedValue": "",
    "name": "标题",
    "icon": "icon-preview",
    "componentName": "title",
    "deleteAble": true,
    "column": true,
    "uniqe": 1,
    "id": "UK9",
    "formSetting": {
      "value": "",
      "type": "titleSettings",
      "id": "UK9",
      "children": [
        {
          "value": "标题",
          "placeholder": "请输入",
          "param": "label",
          "rule": {
            "required": true,
            "trigger": [
              "blur"
            ],
            "msg1": "1111",
            "msg2": "组件标题不能重复!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "组件标题:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disabled": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "title",
          "placeholder": "请输入",
          "param": "tag",
          "rule": {
            "required": true,
            "trigger": [
              "blur"
            ],
            "message": "组件标签必填!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "组件标签:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disabled": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "",
          "placeholder": "请输入",
          "param": "placeholder",
          "rule": {
            "required": false,
            "trigger": [
              "blur"
            ],
            "msg1": "1111",
            "msg2": "组件提示不能重复!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "组件提示:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disable": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "",
          "placeholder": "请输入",
          "param": "helpMsg",
          "rule": {
            "required": false,
            "trigger": [
              "blur"
            ],
            "msg1": "1111",
            "msg2": "帮助信息不能重复!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "帮助信息:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disable": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "是",
          "param": "rule",
          "rule": {
            "required": false,
            "trigger": [
              "blur"
            ],
            "msg1": "",
            "msg2": "",
            "api": "",
            "key": "siteDomain",
            "params": {}
          },
          "label": "是否必填:",
          "marginLeft": 0,
          "type": "keyValue",
          "isBoolean": true,
          "options": [
            "是",
            "否"
          ],
          "tips": ""
        }
      ]
    }
  },
  {
    "value": "",
    "placeholder": "请输入",
    "param": "shortTitle",
    "rule": {
      "required": false,
      "trigger": [
        "blur"
      ],
      "msg1": "副标题不能为空!",
      "msg2": "名称不能重复!",
      "api": "fetchOssNameUnique",
      "key": "siteDomain",
      validator: checkNameForm,
      "params": {}
    },
    "label": "副标题:",
    "beforeText": "",
    "afterText": "",
    "helpMsg": "",
    "api": "fetchOssNameUnique",
    "width": 492,
    "maxCount": 200,
    "showCount": true,
    "marginLeft": 32,
    "marginTop": 0,
    "type": "textInput",
    "associated": "",
    "associatedValue": "",
    "name": "副标题",
    "icon": "icon-preview",
    "componentName": "shortTitle",
    "deleteAble": false,
    "column": true,
    "uniqe": 1,
    "id": "GJxL",
    "formSetting": {
      "value": "",
      "type": "shortTitleSettings",
      "id": "GJxL",
      "children": [
        {
          "value": "副标题",
          "placeholder": "请输入",
          "param": "label",
          "rule": {
            "required": true,
            "trigger": [
              "blur"
            ],
            "msg1": "1111",
            "msg2": "组件标题不能重复!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "组件标题:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disabled": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "shortTitle",
          "placeholder": "请输入",
          "param": "tag",
          "rule": {
            "required": true,
            "trigger": [
              "blur"
            ],
            "message": "组件标签必填!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "组件标签:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disabled": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "",
          "placeholder": "请输入",
          "param": "placeholder",
          "rule": {
            "required": false,
            "trigger": [
              "blur"
            ],
            "msg1": "1111",
            "msg2": "组件提示不能重复!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "组件提示:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disable": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": "",
          "placeholder": "请输入",
          "param": "helpMsg",
          "rule": {
            "required": false,
            "trigger": [
              "blur"
            ],
            "msg1": "1111",
            "msg2": "帮助信息不能重复!",
            "api": "fetchOssNameUnique",
            "key": "siteDomain",
            "params": {}
          },
          "label": "帮助信息:",
          "beforeText": "",
          "afterText": "",
          "width": "",
          "showCount": false,
          "disable": true,
          "marginLeft": 0,
          "marginTop": 0,
          "type": "textInput",
          "associated": "",
          "associatedValue": ""
        },
        {
          "value": false,
          "param": "rule",
          "rule": {
            "required": false,
            "trigger": [
              "blur"
            ],
            "msg1": "",
            "msg2": "",
            "api": "",
            "key": "siteDomain",
            "params": {}
          },
          "label": "是否必填:",
          "marginLeft": 0,
          "type": "radio",
          "isBoolean": true,
          "options": [
            "是",
            "否"
          ],
          "tips": ""
        }
      ]
    }
  },
  {
    "componentName": "",
    "uedit_list": [
      {
        "value": "",
        "param": "contents",
        "picId": "",
        "picIdPram": "",
        "rule": {
          "required": false,
          "trigger": [
            "change"
          ],
          "msg1": "请上传附件！",
          "msg2": "",
          "api": "",
          "key": "siteDomain",
          "params": {}
        },
        "label": "",
        "beforeText": "",
        "afterText": "",
        "maxCount": 1,
        "marginLeft": 32,
        "accept": "",
        "uploadTitle": "上传附件",
        "multiple": true,
        "extra": "",
        "type": "singlePictrueUpload",
        "optionValue": "",
        "associated": "",
        "associatedValue": true,
        "listType": "text",
        "name": "正文",
        "icon": "icon-a-Richtext",
        "componentName": "contents",
        "uniqe": 1,
        "id": "Y8f",
        "deleteAble": false,
        "formSetting": {
          "value": "",
          "type": "contentsSettings",
          "id": "VnbE",
          "children": [
            {
              "value": "",
              "placeholder": "请输入",
              "param": "label",
              "rule": {
                "required": true,
                "trigger": [
                  "blur"
                ],
                "msg1": "1111",
                "msg2": "组件标题不能重复!",
                "api": "fetchOssNameUnique",
                "key": "siteDomain",
                "params": {}
              },
              "label": "组件标题:",
              "beforeText": "",
              "afterText": "",
              "width": 304,
              "showCount": false,
              "disabled": true,
              "marginLeft": 0,
              "marginTop": 0,
              "type": "textInput",
              "associated": "",
              "associatedValue": ""
            },
            {
              "value": "contents",
              "placeholder": "请输入",
              "param": "tag",
              "rule": {
                "required": true,
                "trigger": [
                  "blur"
                ],
                "message": "组件标签必填!",
                "api": "fetchOssNameUnique",
                "key": "siteDomain",
                "params": {}
              },
              "label": "组件标签:",
              "beforeText": "",
              "afterText": "",
              "width": 304,
              "showCount": false,
              "disabled": true,
              "marginLeft": 0,
              "marginTop": 0,
              "type": "textInput",
              "associated": "",
              "associatedValue": ""
            },
            {
              "value": "",
              "placeholder": "请输入",
              "param": "helpMsg",
              "rule": {
                "required": false,
                "trigger": [
                  "blur"
                ],
                "msg1": "1111",
                "msg2": "帮助信息不能重复!",
                "api": "fetchOssNameUnique",
                "key": "siteDomain",
                "params": {}
              },
              "label": "帮助信息:",
              "beforeText": "",
              "afterText": "",
              "width": 304,
              "showCount": false,
              "disable": true,
              "marginLeft": 0,
              "marginTop": 0,
              "type": "textInput",
              "associated": "",
              "associatedValue": ""
            }
          ]
        },
        "key": 0,
        "closable": false,
        "tabLabel": "正文"
      }
    ],
    "settingObj": {
      "afterText": "",
      "api": "",
      "associated": "",
      "associatedValue": "",
      "beforeText": "",
      "column": true,
      "componentName": "isDownloadImag",
      "formSetting": {
        "value": "",
        "type": "isDownloadImagSettings",
        "id": "NYSa",
        "children": [
          {
            "value": "",
            "placeholder": "请输入",
            "param": "label",
            "rule": {
              "required": true,
              "trigger": [
                "blur"
              ],
              "msg1": "1111",
              "msg2": "组件标题不能重复!",
              "api": "fetchOssNameUnique",
              "key": "siteDomain",
              "params": {}
            },
            "label": "",
            "beforeText": "",
            "afterText": "",
            "width": "",
            "showCount": false,
            "disabled": true,
            "marginLeft": 0,
            "marginTop": 0,
            "type": "textInput",
            "associated": "",
            "associatedValue": ""
          },
          {
            "value": "keyWord",
            "placeholder": "请输入",
            "param": "tag",
            "rule": {
              "required": true,
              "trigger": [
                "blur"
              ],
              "message": "组件标签必填!",
              "api": "fetchOssNameUnique",
              "key": "siteDomain",
              "params": {}
            },
            "label": "组件标签:",
            "beforeText": "",
            "afterText": "",
            "width": "",
            "showCount": false,
            "disabled": true,
            "marginLeft": 0,
            "marginTop": 0,
            "type": "textInput",
            "associated": "",
            "associatedValue": ""
          },
          {
            "value": "",
            "placeholder": "请输入",
            "param": "helpMsg",
            "rule": {
              "required": false,
              "trigger": [
                "blur"
              ],
              "msg1": "1111",
              "msg2": "帮助信息不能重复!",
              "api": "fetchOssNameUnique",
              "key": "siteDomain",
              "params": {}
            },
            "label": "帮助信息:",
            "beforeText": "",
            "afterText": "",
            "width": "",
            "showCount": false,
            "disable": true,
            "marginLeft": 0,
            "marginTop": 0,
            "type": "textInput",
            "associated": "",
            "associatedValue": ""
          },
          {
            "value": false,
            "param": "rule",
            "rule": {
              "required": false,
              "trigger": [
                "blur"
              ],
              "msg1": "",
              "msg2": "",
              "api": "",
              "key": "siteDomain",
              "params": {}
            },
            "label": "是否必填:",
            "marginLeft": 0,
            "type": "radio",
            "isBoolean": true,
            "options": [
              "是",
              "否"
            ],
            "tips": ""
          }
        ]
      },
      "helpMsg": "",
      "icon": "icon-preview",
      "id": "NYSa",
      "label": "下载远程图片:",
      "marginLeft": 0,
      "marginTop": 0,
      "maxCount": 120,
      "name": "",
      "param": "isDownloadImag",
      "placeholder": "请输入",
      "rule": {
        "required": false,
        "trigger": [],
        "msg1": "1111",
        "msg2": "名称不能重复!",
        "key": "siteDomain"
      },
      "type": "",
      "uniqe": 1,
      "value": false,
      "width": 492
    }
  }
]
export { defaultLeftComp }